package com.bhs.sansonglogistics.ui.mine;

import static android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE;
import static com.bhs.sansonglogistics.bean.ChatBean.TYPE_SENT_TEXT;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.bean.ChatBean;
import com.bhs.sansonglogistics.ui.adapter.ChatAdapter;
import com.bhs.sansonglogistics.utils.SharedPreferencesUtils;

/**
 * 联系客服
 */
public class CustomerServiceActivity extends BaseActivity {

    private RecyclerView mRvList;
    private EditText mEtMessage;
    private ChatAdapter chatAdapter;

    @Override
    public int initLayout() {
        return R.layout.activity_customer_service;
    }

    @Override
    public void initView() {
        TextView mTvTitle = findViewById(R.id.tv_title);
        mTvTitle.setText("联系客服");
        mRvList = findViewById(R.id.rv_list);
        mEtMessage = findViewById(R.id.et_message);
        chatAdapter = new ChatAdapter();
        mRvList.setAdapter(chatAdapter);
        mRvList.setLayoutManager(new LinearLayoutManager(mContext));
    }

    @Override
    public void initData() {
        mEtMessage.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEND) {
                    chatAdapter.addData(new ChatBean(mEtMessage.getText().toString()));
                    mEtMessage.setText("");
                }
                return true;
            }
        });
    }
}